$(function() {
	if (GBrowserIsCompatible()) {
		var gmap = document.getElementById("gmap");
		var street = document.getElementById("gmap-street-view"); 
		var map = new GMap2(gmap);
		var geocoder = new GClientGeocoder();
		var address = $('#address').text().replace(/^[\s\t\r\n]+/g, '').replace(/[\s\t\r\n]+$/g, '');
		
		function showAddress(address) {
			geocoder.getLatLng(
				address,
				function(point) {
					if (point) {
						map.addControl(new GSmallMapControl());
						map.addControl(new GMapTypeControl());
						gmap.style.visibility = 'visible';
						map.setCenter(point, 15);
						var marker = new GMarker(point);
						map.addOverlay(marker);
						
						function showPanoData(panoData) {
							if (panoData.code != 200) {
								return;
							}
							panoramaOptions = { latlng:point };
							var streetPanorama = new GStreetviewPanorama(street, panoramaOptions);
							street.style.display = 'block';
						}
						panoClient = new GStreetviewClient();
						panoClient.getNearestPanorama(point, showPanoData);
						$('#gmap-about-text').show();
					} else {
						gmap.style.display = 'none';
						street.style.display = 'none';
					}
				}
			);
		}

		showAddress(address);
	}
});
